/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.exception;

/**
 * @author haolw
 * @time 2017/06/27
 */
public enum ErrorType {
    SUCCESS(0, "Success", "Success"),
    SYSTEM_ERROR(800, "系统错误", "system error"),
    SERVER_FAILURE(801, "服务器处理失败", "server failure"),
    MAIL_FAILURE(802, "邮件发送失败", "mail failure"),
    NOT_EXIST_RECORD(803, "不存在的数据", "the data does not exist"),
    NO_AUTH(804, "无权限", "no auth"),
    AUTH_FAIL(805, "授权失败", "auth failed"),
    NO_SERVICE(806, "无服务", "no service"),
    INVALID_TOKEN(808, "无效的token", "invalid token"),
    NO_OPEN_SERVICE(809, "未开通该服务", "no open service"),
    NO_USER(90003, "该用户不存在", "user does not exist"),
    REGISTERED_PHONE(90004, "手机号已被注册", "phone number has been registered"),
    INVALID_ACCOUNT(90010, "账号无效", "account invalid"),
    INVALID_COMPANY(90011, "不存在该公司", "company invalid"),
    INVALID_PAYCODE(90012, "失效的支付码", "paycode invalid"),
    NO_SUPPORT_PAYMENT(90013, "不支持的支付", "no support payment"),
    INCOMPLETE_PARAMETERS(90020, "参数不完整", "incomplete parameters"),
    UNLAWFUL_PARAMETERS(90021, "不合法的参数", "unlawful parameters"),
    INVALID_FEE(90022, "无效的金额", "invalid fee"),
    REPEATED_DATA(90023, "重复的数据", "repeated data"),
    SIGNATURE_ERROR(90024, "签名错误", "signature error"),
    PLACE_ORDER_FAILURE(90030, "下单失败", "place order failure"),
    OUT_ORDER_QUERY_FAILURE(90031, "订单查询失败", "query out order failure"),
    RED_PACKET_NOT_EXIST(90100, "没有可领取的红包", "No red packet"),
    RED_PACKET_LIMIT(90101, "今日红包数达到上限", "red packet limit"),
    RED_PACKET_TASK(90102, "观看广告后才能领红包", "Look at the red envelope in the advertisement"),
    CHECK_CODE_LIMIT(90200, "超过验证码每日发送数量", "Times out"),
    CHECK_CODE_SEND_ERROR(90201, "验证码发送失败", "Check code send error"),
    CHECK_CODE_UNABLE(90202, "无效的验证码", "Check code unable"),
    CHECK_CODE_TIME_OUT(90203, "验证码已过期", "Check code timeout"),

    AWARD_LIST_FAIL(90300, "奖品列表获取失败", "奖品列表获取失败"),
    AWARD_FAIL(90301, "抽奖信息获取失败", "抽奖信息获取失败"),

    ;

    private Integer code;
    private String zhCnMsg;
    private String enMsg;

    ErrorType(Integer code, String zhCnMsg, String enMsg) {
        this.code = code;
        this.zhCnMsg = zhCnMsg;
        this.enMsg = enMsg;
    }

    public static ErrorType get(Integer code) {
        for (ErrorType errorType : ErrorType.values()) {
            if (errorType.getCode().equals(code)) {
                return errorType;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getZhCnMsg() {
        return zhCnMsg;
    }

    public void setZhCnMsg(String zhCnMsg) {
        this.zhCnMsg = zhCnMsg;
    }

    public String getEnMsg() {
        return enMsg;
    }

    public void setEnMsg(String enMsg) {
        this.enMsg = enMsg;
    }
}
